package com.study.d028shape3d;

import javafx.application.Application;
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
import javafx.scene.DepthTest;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**3D入门讲解
*@description
*@author xtayhame
*date 2020年3月21日
*version
*since v1.0
*/
public class HelloWord extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		//要设置背景透明，否则立体效果无法显示
		anchorPane.setStyle("-fx-background-color:#FF3E9600");
		System.out.println("判断是否支持3D："+Platform.isSupported(ConditionalFeature.SCENE3D));
		Button b1 = new Button("button1");
		//设置Z坐标
		b1.setTranslateZ(0);
		//b1.setDepthTest(DepthTest.ENABLE);


		Button b2 = new Button("button2");
		b2.setTranslateZ(200);
		//默认继承父组件
		//b2.setDepthTest(DepthTest.ENABLE);

		Button b3 = new Button("button3");
		b3.setTranslateZ(400);
		//b3.setDepthTest(DepthTest.ENABLE);

		anchorPane.getChildren().addAll(b1,b2,b3);
		//true:启用3D效果
		Scene scene = new Scene(anchorPane, 600, 400, true);
		scene.setCamera(new PerspectiveCamera());
		stage.setScene(scene);
		stage.show();

	}
}
